function discard() {
	document.getElementById('titleInput').value = '';
	document.getElementById('storyInput').value = '';

	document.getElementById('useCurrent').checked = true;
	document.getElementById('selectFromMap').checked = false;

	document.getElementById('private').checked = true;
	document.getElementById('public').checked = false;


	document.getElementById('owner').value = '';
	document.getElementById('tag').value = '';

	document.getElementById('media').value = '';
}

function create() {
	var title = document.getElementById('titleInput').value;
	var story = document.getElementById('storyInput').value;
	var useCurrent = document.getElementById('useCurrent').checked;
	var permission = document.getElementById('private').checked;
	var owners = document.getElementById('owner').value;
	var tags = document.getElementById('tag').value;

	if(title === '' || story === '' || tags == '') {
		alert('Empty field');
	}

	if(useCurrent) {
		navigator.geolocation.getCurrentPosition(function(position) {
	        var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
	        myLatLng = pos;
	        map.setCenter(pos);
	      }, function(error) {
	        switch(error.code) 
	        {
	          case error.PERMISSION_DENIED:
	            alert("User denied the request for Geolocation.");
	            break;
	          case error.POSITION_UNAVAILABLE:
	            alert("Location information is unavailable.");
	            break;
	          case error.TIMEOUT:
	            alert("The request to get user location timed out.");
	            break;
	          case error.UNKNOWN_ERROR:
	            alert("An unknown error occurred.");
	            break;
	        }
        });
	}
	else if(!myLatLng) {
		alert('Choose a location or select Use my current location');
	}

	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("POST","http://titan.cmpe.boun.edu.tr:8085/StoryRoadServer/CreateStory?title=" + title + "&body=" + story + "&location=" + myLatLng + "&coordinates=" + myLatLng + "&request_type=Web" ,true);
	xmlhttp.send();
}

